package multithreading;

import java.util.concurrent.ArrayBlockingQueue;

public class FoodieB extends Thread {
    ArrayBlockingQueue<Integer> queue;

    public FoodieB(ArrayBlockingQueue<Integer> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            if (Desk.count > 0) {
                try {
                    Desk.count = queue.take();
                    System.out.println(Thread.currentThread().getName() + "eating No." + (11 - Desk.count));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            } else {
                break;
            }

        }
    }
}
